package patternrecognition.symbols.forms;

public abstract class Rectangle {

	private final Coordinate upperLeft;

	private final Coordinate lowerRight;

	protected Rectangle(Coordinate upperLeft, Coordinate lowerRight) {
		this.upperLeft = upperLeft;
		this.lowerRight = lowerRight;
	}

	private Coordinate getUpperLeft() {
		return upperLeft;
	}

	private Coordinate getLowerRight() {
		return lowerRight;
	}

	public abstract boolean isFilled();

	public boolean hasSameLeftBorder(Rectangle other) {
		return this.getUpperLeft().getX() == other.getUpperLeft().getX();
	}

	public boolean hasSameRightBorder(Rectangle other) {
		return this.getLowerRight().getX() == other.getLowerRight().getX();
	}

	public boolean hasInnerLeftBorder(Rectangle other) {
		return this.getUpperLeft().getX() > other.getUpperLeft().getX();
	}

	public boolean hasInnerRightBorder(Rectangle other) {
		return this.getLowerRight().getX() < other.getLowerRight().getX();
	}

	public boolean isAdjacent(Rectangle other) {
		return this.getLowerRight().getY() == other.getUpperLeft().getY() - 1;
	}
}
